/*
 * @Author: weikang
 * @Description:
 * @Date: 2024-03-18 20:35:38
 * @LastEditTime: 2024-03-24 10:35:28
 * @FilePath: \env-manager-pc\src\store\modules\dashboard.ts
 */
import entApi from '@/api/modules/ent'
import contractApi from '@/api/modules/contract'

const useDashboardStore = defineStore(
  // 唯一ID
  'dashboard',
  () => {
    const envDashboard = ref<any>({})
    const contractDashboard = ref<any>({})
    const entDashboard = ref<any>({})
    function getEnvDashboard(envOrgObjID: string) {
      entApi.GetEnvOrgStat({ envOrgObjID }).then((res) => {
        envDashboard.value = res
      })
    }

    function getContractDashboard(ownerOrgObjID: string) {
      contractApi.GetOwnerOrgStat({ ownerOrgObjID }).then((res) => {
        contractDashboard.value = res
      })
    }

    function getEntDashboard(enterpriseObjIDs: string[]) {
      entApi.GetEnterpriseStat({ enterpriseObjIDs }).then((res) => {
        entDashboard.value = res[enterpriseObjIDs[0]]
      })
    }
    return {
      envDashboard,
      getEnvDashboard,
      getContractDashboard,
      contractDashboard,
      getEntDashboard,
      entDashboard,
    }
  },
)

export default useDashboardStore
